package ioperation;

import Book.Book;
import Book.BookShelf;

import java.util.Scanner;

public class FindOperation implements IOperation{
    public void work(BookShelf bookShelf){
        System.out.println("请输入你要查找的书的名称：");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        int count= bookShelf.getNum();
        System.out.println("查找图书中....");
        for (int i = 0; i < count; i++) {
            Book book=bookShelf.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("找到这本书了！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有你要找的这本书！");



    }
}
